<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/database.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/profile.php';

	//Ensure it's not the logged in user
	if (!isset($_SESSION['user']) || $user['id'] == $_SESSION['user']) {
		header("Location:http://" . $_SERVER['HTTP_HOST'] . '/deviantpic/index.php');
		die();
	}

	require_once $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/doctype.php';
?>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<script type="text/javascript" src="/deviantpic/script/chat.js"></script>
        <title>deviantPIC - Chat with <?php echo $user['username'] ?></title>
    </head>
    <body onload=<?php echo '"refresh_chat(' . $_SESSION['user'] . ", " . $user['id'] . ')"' ?>>
		<!-- Header -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/header.php'; ?>

		<!-- Content -->
		<div id="body">

			<h3>Currently chatting with <?php echo $user['username'] ?></h3>
		
			<script type="text/javascript" >checkChat()</script>

			<!-- Chat -->
			<div id="chat">
				<div id="chat-window">
				</div>
				<div id="chat-form">
					<form action="" ><p>
						<textarea cols="32" rows="2" id="chat-input-message"></textarea>
						<input type="button" value="Send" onclick=<?php echo '"send_chat(' . "'chat-input-message'" . ', ' . $_SESSION['user'] . ", " . $user['id'] . ')"' ?> />
					</p></form>
				</div>
			</div>
		</div>

		<!-- Footer -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/footer.php'; ?>
    </body>
</html>